////////////////////////////////////////////////////////////////////////////////////////
//
// JSimpleSim - A machine language simulator based on SimpSim by Anne-Gert Bultena.
//
// Copyright (C) 2008 Gerardo Camorlinga, Ryan Fitzgerald, and RJ Gordon
//
// This file is part of JSimpleSim.
//
// JSimpleSim is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// JSimpleSim is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JSimpleSim.  If not, see <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////////////

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jsimplesim.view.renderers;

import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;

import org.apache.log4j.Logger;

import jsimplesim.model.MemHexTableModel;

import jsimplesim.view.renderers.StackColorCellRenderer;

/**
 * 
 * @author f08maroon
 */
public class MemRedCellRenderer extends DefaultTableCellRenderer {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3252851573719176257L;
	private static final Color hexBackground = Color.white;
	@SuppressWarnings("unused")
	private static int lastRowEdited;
	@SuppressWarnings("unused")
	private static int lastColEdited;
	static Logger logger = Logger.getLogger(MemRedCellRenderer.class);

	/**
     *
     */
	public MemRedCellRenderer() {
		lastRowEdited = -1;
		lastColEdited = -1;
	}

	/**
	 * 
	 * @param row
	 * @param col
	 */
	public MemRedCellRenderer(int row, int col) {
		lastRowEdited = row;
		lastColEdited = col;
	}

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {

		super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
				row, column);
		
		MemHexTableModel mtm = (MemHexTableModel) table.getModel();
		if (mtm.getNewItem()[row][column]) {
			setForeground(Color.RED);

		} else {
			setForeground(Color.BLACK);
		}
		if(mtm.getIndex() > 150){
			StackColorCellRenderer colorStack = new StackColorCellRenderer();
			setBackground(colorStack.setColor());
		}else{
			

			setBackground(hexBackground);
		}
		setHorizontalAlignment(CENTER);

		return this;
	}
	
}
